package controller

import (
	"github.com/gin-gonic/gin"
	"go_code/gin-blog/service"
	"log"
	"net/http"
)

func GetArticleDetils(c *gin.Context) {
	articleId := c.Query("article_id")
	//categoryId := c.Query("category_id")
	detail, err := service.GetArticleDetail(articleId)
	if err != nil {
		c.HTML(http.StatusInternalServerError, "500.html", nil)
	}
	category, err := service.GetAllCategoryList()
	if err != nil {
		c.HTML(http.StatusInternalServerError, "500.html", nil)
	}
	comment_list, err := service.GetCommentList(articleId)
	if err != nil {
		c.HTML(http.StatusInternalServerError, "500.html", nil)
	}
	//relative_article, err := service.Get
	log.Println("detail=", detail)
	c.HTML(http.StatusOK, "views/detail.html", gin.H{
		"detail":       detail,
		"category":     category,
		"comment_list": comment_list,
		//"relative_article": relative_article,
	})
}
